<script src="__PUBLIC__/ganged/Js/city-picker.data.js"></script>
<script src="__PUBLIC__/ganged/Js/city-picker.js"></script>
<script src="__PUBLIC__/ganged/Js/main.js"></script>
<!-- css -->
<link href="__PUBLIC__/ganged/Css/bootstrap.css" rel="stylesheet" type="text/css" />
<link href="__PUBLIC__/ganged/Css/city-picker.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" charset="utf-8" src="__PUBLIC__/admin/js/uploadify/jquery.uploadify.min.js" ></script>
<link rel="stylesheet" charset="utf-8" type="text/css" href="__PUBLIC__/admin/js/uploadify/uploadify.css"> 
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/admin/js/upload.js" ></script>
<!-- 定位 -->
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=yWnFso0oyjmX79HzCx1DRz2sBtvweQfI"></script>
<style>
.bg{ background: none; border: none;}
.uploadify-button-text{ display: inline-flex; }
.uploadify-button-text button{ margin: -10px; }
.upviewer img{ height:90px; width: 120px; }
.upviewer ul{ margin:0px; padding:0px; }
.upviewer li{ margin:0px; padding:0px; position: relative; display:inline-block; width:120px; height:90px; background-position: center; background-size: contain; background-repeat: no-repeat; float: left; margin-right:10px; border:1px #ccc solid; background-color:#f0f0f0;}
.upviewer li a{ display:inline-block; position: absolute; bottom:0px; left:0px; text-align:center; width:100%; background-color:rgba(0,0,0,0.3); color:red; cursor: pointer; }
.upviewer li:hover a{ background-color:rgba(0,0,0,0.8); }
</style>
<div class="container" style="padding-top: 50px;">
    <div class="row clearfix">
        <div class="col-md-12 column">
            <form class="form-horizontal" role="form" id="post_form" action="{:U('edit')}">
                <div class="form-group">
                    <label for="title" class="col-sm-2 control-label">棋牌室名称:<span style="color: red;">*</span></label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="card_room" id="card_room" value="{$info.card_room}" />
                    </div>
                </div>
                <div class="form-group">
                     <label for="title" class="col-sm-2 control-label">申请人姓名:<span style="color: red;">*</span></label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="applicant_name" id="applicant_name" value="{$info.applicant_name}" />
                    </div>
                </div>
                <div class="form-group">
                     <label for="title" class="col-sm-2 control-label">电话:<span style="color: red;">*</span></label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="mobile" id="mobile" value="{$info.mobile}" />
                    </div>
                </div>
                <div class="form-group">
                     <label for="title" class="col-sm-2 control-label">地址:<span style="color: red;">*</span></label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="address" id="address" value="{$info.address}" />
                    </div>
                </div>
                <!-- <div class="form-group">
                     <label for="title" class="col-sm-2 control-label">身份证号:<span style="color: red;">*</span></label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="id_card" id="id_card" value="{$info.id_card}" />
                    </div>
                </div> -->
                <div class="form-group">
                     <label for="title" class="col-sm-2 control-label">免费日期:<span style="color: red;">*</span></label>
                    <div class="col-sm-5">
                        <input type="date" class="form-control" name="free_date" id="free_date" value="{:date('Y-m-d', $info['free_date'])}" />
                    </div>
                </div>
                <div class="form-group">
                    <label for="business_license" class="col-sm-2 control-label">营业执照:</label>
                    <div class="col-sm-10 js_upload_imgs">
                        <input type="file" class="form-control" id="business_license"><br /> 
                        <div name="business_license" class="upviewer">
                            <ul>
                                <notempty name="info['business_license']">
                                    <php>
                                        $info['business_license'] = explode(',', $info['business_license']) ;
                                    </php>
                                    <volist name="info['business_license']" id="img">
                                        <li>
                                            <input type="hidden" name="business_license[]" value="{$img}">
                                            <img src="{$img}"/><a d_path="{$img}">删除</a>
                                        </li>
                                    </volist>
                                </notempty>
                            </ul>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">状态:</label>
                    <div class="col-sm-10">
                        <label for="is_status1" class="control-label">
                            <input type="radio" id="is_status1" name="status" value="0" <if condition="$info['status'] neq 1">checked</if>>关闭
                        </label>
                        <label for="is_status2" class="control-label">
                            <input type="radio" id="is_status2" name="status" value="1"  <if condition="$info['status'] eq 1">checked</if>>开启
                        </label>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <input type="hidden" name="id" value="{$info.id}">
                        <button type="button" class="btn btn-primary" id="btn" lng="0" lat="0">提交</button>
                    </div>
                </div>
            </form>
        </div>
</div>
<script>
function getPlace(addr, callback) {
    var myGeo = new BMap.Geocoder();
    var lng = 0;
    var lat = 0;
    myGeo.getPoint(addr, function(point) {
        if(point) {
            lng = point.lng;
            lat = point.lat;
        }
        callback({'lat':lat, 'lng':lng})
    });
}   
$(function(){
     
    $("#btn").click(function(){
        // 省市区
        var pcd = $("#city-picker3").val();
        var $form = $("#post_form");
        var $data = {};
        var $form_data = $form.serializeArray();
        $.each($form_data, function(k, v){
            $data[v['name']] = v['value'];
        })
        $data['pcd'] = pcd;
        
        var submit = function(point){
            // $data['lat'] = typeof(point['lat']) != 'undefined' ? point['lat'] : 0;
            // $data['lng'] = typeof(point['lng']) != 'undefined' ? point['lng'] : 0;
            $.post($form.attr('action'), $data, function(obj){
                alert(obj.m);
                if(obj.s){
                    if(typeof(obj.url)!= "undefined" && obj.url){
                        location.href = obj.url;
                    }
                }
            })
        }
        address = '';//pcd.split("/").join("")+$data['address'];
        if(address){
            // 获取经纬
            getPlace(address, submit);
        }else{
            submit({});
        }
    })
});
</script>
